<?php

namespace app\admin\validate;

use app\admin\logic\system\LoginLogic;
use think\Validate;

class LoginValidate extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require',
        'yzm'      => 'require|yzm',
    ];

    protected $message  =   [
        'username.require'  => '请输入用户名',
        'password.require'  => '请输入密码',
        'yzm.require'       => '请输入验证码',
        'yzm.yzm'           => '验证码错误',
    ];

    // 验证验证码是否正确
    protected function yzm($value, $rule)
    {
        //return true;
        return strtoupper($value) === strtoupper(LoginLogic::getYzm());
    }
}